home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / xulrunner-1.9.0.14 / chrome / pippki.jar / content / pippki / PageInfoOverlay.xul < prev    next >
Encoding:
Extensible Markup Language  |  2008-04-02  |  9.6 KB  |  265 lines

  1. <?xml version="1.0"?>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.    -
  5.    - The contents of this file are subject to the Mozilla Public License Version
  6.    - 1.1 (the "License"); you may not use this file except in compliance with
  7.    - the License. You may obtain a copy of the License at
  8.    - http://www.mozilla.org/MPL/
  9.    -
  10.    - Software distributed under the License is distributed on an "AS IS" basis,
  11.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.    - for the specific language governing rights and limitations under the
  13.    - License.
  14.    -
  15.    - The Original Code is mozilla.org code.
  16.    -
  17.    - The Initial Developer of the Original Code is
  18.    - Netscape Communications Corp.
  19.    - Portions created by the Initial Developer are Copyright (C) 2001
  20.    - the Initial Developer. All Rights Reserved.
  21.    -
  22.    - Contributor(s):
  23.    -   Terry Hayes <thayes@netscape.com>
  24.    -
  25.    - Alternatively, the contents of this file may be used under the terms of
  26.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  27.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.    - in which case the provisions of the GPL or the LGPL are applicable instead
  29.    - of those above. If you wish to allow use of your version of this file only
  30.    - under the terms of either the GPL or the LGPL, and not to allow others to
  31.    - use your version of this file under the terms of the MPL, indicate your
  32.    - decision by deleting the provisions above and replace them with the notice
  33.    - and other provisions required by the GPL or the LGPL. If you do not delete
  34.    - the provisions above, a recipient may use your version of this file under
  35.    - the terms of any one of the MPL, the GPL or the LGPL.
  36.    -
  37.    - ***** END LICENSE BLOCK ***** -->
  38.  
  39. <!-- This file extends "chrome://navigator/content/pageInfo.xul" -->
  40.  
  41. <!DOCTYPE overlay SYSTEM "chrome://pippki/locale/PageInfoOverlay.dtd">
  42.  
  43. <overlay id="pipPageInfoOverlayID"
  44.          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
  45.   <script type="application/x-javascript" src="chrome://global/content/strres.js"/>
  46.   <script type="application/x-javascript" src="chrome://pippki/content/pippki.js"/>
  47.   <script type="application/x-javascript">
  48.   <![CDATA[
  49.     var security = {
  50.       // Display the server certificate (static)
  51.       viewCert : function () {
  52.         var cert = security._cert;
  53.         viewCertHelper(window, cert);
  54.       },
  55.  
  56.       _getSecurityInfo : function() {
  57.         const nsIX509Cert = Components.interfaces.nsIX509Cert;
  58.         const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
  59.         const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
  60.         const nsISSLStatusProvider = Components.interfaces.nsISSLStatusProvider;
  61.         const nsISSLStatus = Components.interfaces.nsISSLStatus;
  62.  
  63.         // Get the window for this information
  64.         var w;
  65.         if ("arguments" in window && window.arguments.length > 0 &&
  66.             window.arguments[0] && window.arguments[0].doc)
  67.         {
  68.           w = window.arguments[0].doc.defaultView;
  69.           if (w != w.top) {
  70.             // We don't have separate info for a frame, return null until further notice
  71.             // (see bug 138479)
  72.             return null;
  73.           }
  74.         }
  75.         else if ("gBrowser" in window.opener)
  76.           w = window.opener.gBrowser.contentWindow;
  77.         else
  78.           w = window.opener.frames[0];
  79.  
  80.         var hName = null;
  81.         try
  82.         {
  83.            hName = w.location.host;
  84.         } catch(exception){}
  85.  
  86.         var ui = security._getSecurityUI();
  87.         var status = null;
  88.         var sp = null;
  89.         var isBroken = false;
  90.         if (ui) {
  91.           isBroken = (ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_BROKEN);
  92.           if (!(ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_INSECURE)) {
  93.             sp = ui.QueryInterface(nsISSLStatusProvider);
  94.             if (sp)
  95.               status = sp.SSLStatus;
  96.           }
  97.         }
  98.         if (status) {
  99.           status = status.QueryInterface(nsISSLStatus);
  100.         }
  101.         if (status) {
  102.           var cert = status.serverCert;
  103.           var issuerName;
  104.  
  105.           issuerName = this.mapIssuerOrganization(cert.issuerOrganization);
  106.           if (!issuerName) issuerName = cert.issuerName;
  107.         
  108.           return {
  109.             hostName : hName,
  110.             cAName : issuerName,
  111.             encryptionAlgorithm : status.cipherName,
  112.             encryptionStrength : status.secretKeyLength,
  113.             isBroken : isBroken,
  114.             cert : cert
  115.           };
  116.         } else {
  117.           return {
  118.             hostName : hName,
  119.             cAName : "",
  120.             encryptionAlgorithm : "",
  121.             encryptionStrength : 0,
  122.             isBroken : isBroken,
  123.             cert : null
  124.           };
  125.         } 
  126.       },
  127.  
  128.       // Find the secureBrowserUI object (if present)
  129.       _getSecurityUI : function() {
  130.         if ("gBrowser" in window.opener)
  131.           return window.opener.gBrowser.securityUI;
  132.         return null;
  133.       },
  134.  
  135.       // Interface for mapping a certificate issuer organization to
  136.       // the value to be displayed.
  137.       // Bug 82017 - this implementation should be moved to pipnss C++ code
  138.       mapIssuerOrganization: function(name) {
  139.         if (!name) return null;
  140.  
  141.         if (name == "RSA Data Security, Inc.") return "Verisign, Inc.";
  142.  
  143.         // No mapping required
  144.         return name;
  145.       },
  146.  
  147.       _cert : null
  148.     };
  149.  
  150.     function securityOnLoad() {
  151.       var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
  152.  
  153.       var info = security._getSecurityInfo();
  154.       if (!info) {
  155.         document.getElementById("securityTab").setAttribute("hidden", true);
  156.         return;
  157.       }
  158.  
  159.       var idHdr;
  160.       var message1;
  161.       var message2;
  162.  
  163.       /* Set the identification messages */
  164.       if (info.cert)
  165.       {
  166.         idHdr = bundle.GetStringFromName("pageInfo_WebSiteVerified");
  167.         setText("security-identity", idHdr);
  168.  
  169.         message1 = bundle.formatStringFromName("pageInfo_Identity_Verified", 
  170.                                 [ info.hostName, info.cAName ],
  171.                                 2);
  172.         setText("security-identity-text", message1);
  173.  
  174.         var viewText = bundle.GetStringFromName("pageInfo_ViewCertificate");
  175.         setText("security-view-text", viewText);
  176.         security._cert = info.cert;
  177.       } else {
  178.         idHdr = bundle.GetStringFromName("pageInfo_SiteNotVerified");
  179.         setText("security-identity", idHdr);
  180.  
  181.         document.getElementById("security-view-cert").setAttribute("disabled", "true");
  182.         document.getElementById("security-view-cert").setAttribute("hidden", "true");
  183.       }
  184.  
  185.       var hdr;
  186.       var msg1;
  187.       var msg2;
  188.       
  189.       /* Set the encryption messages */
  190.       if (info.isBroken) {
  191.         hdr = bundle.GetStringFromName("pageInfo_MixedContent");
  192.         setText("security-privacy", hdr);
  193.  
  194.         msg1 = bundle.GetStringFromName("pageInfo_Privacy_Mixed1");
  195.         setText("security-privacy-msg1", msg1);
  196.  
  197.         msg2 = bundle.GetStringFromName("pageInfo_Privacy_None2");
  198.         setText("security-privacy-msg2", msg2);
  199.       } else if (info.encryptionStrength >= 90) {
  200.         hdr = bundle.formatStringFromName("pageInfo_StrongEncryption",
  201.                              [ info.encryptionAlgorithm, info.encryptionStrength+"" ], 2);
  202.         setText("security-privacy", hdr);
  203.  
  204.         msg1 = bundle.GetStringFromName("pageInfo_Privacy_Strong1");
  205.         setText("security-privacy-msg1", msg1);
  206.  
  207.         msg2 = bundle.GetStringFromName("pageInfo_Privacy_Strong2");
  208.         setText("security-privacy-msg2", msg2);
  209.  
  210.         security._cert = info.cert;
  211.       } else if (info.encryptionStrength > 0) {
  212.         hdr = bundle.formatStringFromName("pageInfo_WeakEncryption",
  213.                              [ info.encryptionAlgorithm, info.encryptionStrength+"" ], 2);
  214.         setText("security-privacy", hdr);
  215.  
  216.         msg1 = bundle.formatStringFromName("pageInfo_Privacy_Weak1",
  217.                                                [ info.hostName ], 1);
  218.         setText("security-privacy-msg1", msg1);
  219.  
  220.         msg2 = bundle.GetStringFromName("pageInfo_Privacy_Weak2");
  221.         setText("security-privacy-msg2", msg2);
  222.       } else {
  223.         hdr = bundle.GetStringFromName("pageInfo_NoEncryption");
  224.         setText("security-privacy", hdr);
  225.  
  226.         if(info.hostName != null)
  227.           msg1 = bundle.formatStringFromName("pageInfo_Privacy_None1", [ info.hostName ], 1);
  228.         else
  229.           msg1 = bundle.GetStringFromName("pageInfo_Privacy_None3");
  230.  
  231.         setText("security-privacy-msg1", msg1);
  232.  
  233.         msg2 = bundle.GetStringFromName("pageInfo_Privacy_None2");
  234.         setText("security-privacy-msg2", msg2);
  235.       }
  236.     }
  237.  
  238.     /* Register for pageInfo onload calls */
  239.     onLoadRegistry.push(securityOnLoad);
  240.   ]]>
  241.   </script>
  242.   <tabs id="tabs">
  243.     <tab id="securityTab" label="&pageInfo.securityTab;"
  244.          accesskey="&pageInfo.securityTab.accesskey;"/>
  245.   </tabs>
  246.   <tabpanels id="tabpanels">
  247.     <vbox id="securityPanel" flex="1">
  248.       <description id="security-identity" class="header"/>
  249.       <description id="security-identity-text" flex="1"/>
  250.       <hbox align="center">
  251.         <button id="security-view-cert" label="&pageInfo.view.label;"
  252.                 accesskey="&pageInfo.view.accesskey;" 
  253.                 oncommand="security.viewCert();"/>
  254.         <description id="security-view-text" flex="1"/>
  255.       </hbox>
  256.       <separator class="groove"/>
  257.       <description id="security-privacy" class="header"/>
  258.       <vbox flex="1">
  259.         <description id="security-privacy-msg1"/>
  260.         <description id="security-privacy-msg2"/>
  261.       </vbox>
  262.     </vbox>
  263.   </tabpanels>
  264. </overlay>
  265.